package com.xdap.fsapproval.util;

import com.definesys.mpaas.common.exception.MpaasBusinessException;
import org.apache.commons.lang.StringUtils;

import java.text.ParseException;
import java.text.SimpleDateFormat;

/**
 * @BelongsProject：IntelliJ IDEA
 * @BelongsPackage：com.adisseo.service.approval.util
 * @Author：fei
 * @CreateTime：2022-09-06 17:43
 * @Description: 时间转换工具类
 * @Version：1.0
 */
public class TimeUtil {

    private static final SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm");

    public static String ConversionTimestamp(String date){
        String result=null;
        if(StringUtils.isBlank(date)){
            throw new MpaasBusinessException("时间戳转换失败,时间为null");
        }else {
            try {
                result= String.valueOf(sdf.parse(date).getTime());
            } catch (ParseException e) {
                e.printStackTrace();
            }
        }
        return result;
    }
}
